<? 
session_start();
if(!session_is_registered(uid)){
    echo "You have to login to view this page!</br></br>";
    echo "Click here to return to the "; 
    echo '<a href="./../index.php" title="Login">Login Page</a></br></br>';
    echo "Or sign up using this link ";
    echo '<a href="./../Registration/registration.html" title="Registration">Registration Page</a>';
exit();
}
else

include 'maintenance.html';

//Manual SQL Connection
    $con = mysql_connect("localhost", "root", "root") or die ( "Error connectiong to DB: ".mysql_error());
       
    mysql_select_db("reeferslog", $con) or die ( "Error selecting specific DB, reefeerslog: ".mysql_error());
    
    //Variables
    $type = $_POST['type'];
    $notes = $_POST['notes'];
    
    
    //Date variables
    $day = $_POST['day'];
    $month = $_POST['month'];
    $year = $_POST['year'];
    
    //Function to make a valid date input if it has a space colon or period as a seperator
    $date = $year."-".$month."-".$day;
    
    //SQL Query
    $addmait = "insert into maintenance (m_date, user_id, type, notes) values ('$date', " . $_SESSION['uid'] . ", '$type','$notes')";
    
    //Execute Insert command
    if (!mysql_query($addmait,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo "Husbandry Activity added successfully!";

    
mysql_close($con);
?>